import { createRouter, createWebHashHistory } from "vue-router";

const router = createRouter({
    history: createWebHashHistory(),
    routes: [
        {
            path: "/",
            redirect: "/Login"
        },
        {
            path: "/Login",
            name: "/Login",
            component: () => import("@/views/Login/Login.vue")
        },
        {
            path: "/Home",
            name:"Home",
            component: () => import("@/views/Home/index.vue"),
            children: []
        }
    ]
})

router.beforeEach((to, from, next) => {
    if (to.path != "/" && to.path != "/Login") {
        if (!localStorage.getItem("username")) {
            next("/Login");
        }
    }
    next();
})

export default router